package work20241207_chap8.g;

/**
 * @author zdl
 * @date 2024/12/7
 */
interface JavaTeacher{
    void teach();
}
class TeacherA implements JavaTeacher{
    public void teach(){
        System.out.println("“TeacherA teach Java”");
    }
}
class TeacherB implements JavaTeacher{
    public void teach(){
        System.out.println("“TeacherB teach Java”");
    }
}
class School{
    public static JavaTeacher getTeacher(int i){
        if (i == 0) return new TeacherA();
        else return new TeacherB();
    }
}
public class TestSchool{
    public static void main(String args[]){
        JavaTeacher jt = School.getTeacher(0);
        jt.teach(); //TeacherA teach Java
        jt = School.getTeacher(10);
        jt.teach();//TeacherB teach Java
    }
}
